package com.itheima;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class IteratorDemo {//迭代器练习
    public static void main(String[] args) {
        Collection<String> collection = new ArrayList<String>();
        collection.add("张三");
        collection.add("李四");
        collection.add("王五");
        collection.add("张文文");

        //获得集合对应的迭代器
        Iterator<String> it = collection.iterator();
        //如果迭代具有更多元素，则返回 true
        while(it.hasNext()){
            //返回迭代中的下一个元素
            System.out.println(it.next());
        }

        ArrayList<String>  arrayList = new ArrayList<String>();
    }
}
